﻿using FluentNHibernate.Mapping;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace GENERIC.NHRepository
{
    public abstract class NHMapping<TEntityType> : ClassMap<TEntityType>
    {
        #region Constructor

        public NHMapping(string schemaName)
        {
            //Table(TableName, schemaName);
            var obj = GetPrimaryKey();
            if (obj != null)
            {
                Id(i=>obj);
            }

            MapProperties();
        }

        #endregion

        #region Properties

        protected abstract void MapTable();

        protected abstract void MapKey();

        protected abstract string TableName { get; }

        protected abstract Expression<Func<TEntityType, object>> GetPrimaryKey();

        #endregion

        #region Methods

        protected abstract void MapProperties();

        #endregion
    }
}
